/* Author: DO HOANG HAI
 * Main.java
 *
 * Created on June 4, 2006, 8:55 PM
 *
* Description: This project demonstrates  how to use sequential search algorithm to search for a value in an one-dimension array 
 */

package sequential;

import java.util.Scanner;

/**
 *
 * @author hai
 */
public class Main {
    
    private static int[] array={5,4,23,74,98,7,43, 95, 2,49};
    private static Scanner reader= new Scanner(System.in);
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        displayOriginalArray();
        System.out.println();
        System.out.println(" Search for: ");
        int value=reader.nextInt();
        int i=0;
        for (i=0; i<array.length; i++)
            if (value== array[i]){
                System.out.println("Answer: " + value +" is found at "+i);                   
            break;
            }
        if (i==array.length)
            System.out.println("Answer: " + value +" is not found");
                
    }
    public static void displayOriginalArray(){
        for (int i=0; i<array.length; i++)
        {
            System.out.print("   " + array[i]);    
        }
            
    }
    
}
